package com.duying.gh.manager;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.duying.gh.GhCommonManager; 
import com.duying.gh.model.BaseXzType;

public class BaseXzTypeManager extends GhCommonManager{
	
	public List getListSelect(){
		String hql = "from BaseXzType x where x.auditing = 1 order by x.type_code asc";
		List list = this.baseDao.getByHQL(hql);
		List listSelect = new ArrayList();
		
		for(Object obj : list){
			int depth = 1;
			BaseXzType c = (BaseXzType)obj;
			Map map = new HashMap();
			map.put("pvalue",c.getType_code() + "  " + c.getType_name());
			map.put("pkey",c.getId());
			listSelect.add(map);
		}
		return listSelect;
	}
	
	public Integer getId(BaseXzType bxt){
		if(bxt == null){
			return 99;
		}else{
			return bxt.getId();
		}
	}

	public List getList(){
		String hql = "from BaseXzType x where x.auditing = 1 order by x.id asc";
		List list = this.baseDao.getByHQL(hql);
		return list;
	}
	
	
	public BaseXzType getByCode(String type_code){
		String hql = "from BaseXzType x where x.type_code =:type_code";
		Map map = new HashMap();
		map.put("type_code", type_code);
		List list = this.baseDao.getByHQL(hql , map);
		if(list.isEmpty()){
			return null;
		}else{
			return (BaseXzType)list.get(0);
		}

	}
}
